package com.imist.nettybasic4.client.console;

import com.imist.nettybasic4.protocol.request.CreateGroupRequestPacket;
import com.imist.nettybasic4.protocol.request.LoginRequestPacket;
import io.netty.channel.Channel;

import java.util.Arrays;
import java.util.Scanner;

public class CreateGroupConsoleCommand implements ConsoleCommand {
    private static final String USER_ID_SPLITER = ",";
    @Override
    public void exec(Scanner scanner, Channel channel) {
        CreateGroupRequestPacket createGroupRequestPacket = new CreateGroupRequestPacket();
        System.out.println("[拉人群聊] 输入 userId 列表，userId之间用英文逗号隔开:");
        String userIds = scanner.next();//这里必须是等待下一个输入，不然的话会和等待指令输入冲突;
        createGroupRequestPacket.setUserIdList(Arrays.asList(userIds.split(USER_ID_SPLITER)));
        channel.writeAndFlush(createGroupRequestPacket);
    }


}
